package com.resjz.milddog.service.order.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.resjz.milddog.dao.roder.OrderDao;
import com.resjz.milddog.entity.order.OrderEntity;
import com.resjz.milddog.service.order.OrderService;
import com.resjz.milddog.vo.order.OrderVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
@Slf4j
@Service("orderService")
public class OrderServiceImpl extends ServiceImpl<OrderDao, OrderEntity> implements OrderService {
    @Override
    public void saveOrder(OrderVo orderVo) {
        OrderEntity orderEntity = new OrderEntity();
        BeanUtil.copyProperties(orderVo,orderEntity);
        this.save(orderEntity);
    }

    @Override
    public OrderVo getOrderByOrderId(Long orderId) {
        try {
            Thread.sleep(1000*2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("order1111111111");
        OrderVo orderVo = new OrderVo();
        List<OrderEntity> orderEntity = this.list(new QueryWrapper<OrderEntity>().eq("user_id",orderId));
        BeanUtil.copyProperties(orderEntity.get(0),orderVo);
        return orderVo;
    }
}
